package cn.ppwx.crm.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import com.google.common.io.CharStreams;

public class IOUtil {
	private final static String ENCODING_UTF_8 = "utf-8";

	public static String streamToString(InputStream inputStream, String encoding) {
	    try {
	    	if (encoding == null)
	    		encoding = ENCODING_UTF_8;
	    	String result = CharStreams.
	    		  toString(new InputStreamReader(inputStream, encoding));
	      return result;
	    } catch (IOException e) {
	    	return null;
	    }
	}
}
